import { HttpClient, HttpClientModule } from '@angular/common/http';
import { ErrorHandler, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { IonicStorageModule, Storage } from '@ionic/storage';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';

import { Items } from '../mocks/providers/items';
import { Settings, User, Api } from '../providers';
import { MyApp } from './app.component';

// 检索
import {IndexListModule} from "ionic3-index-list";

// 相机 文件上传
import { Camera } from '@ionic-native/camera';
import { File } from '@ionic-native/file';
import { FileTransfer } from '@ionic-native/file-transfer';
import { HttpSeriveProvider } from '../providers/http-serive/http-serive';
import { MySeriveProvider } from '../providers/my-serive/my-serive';
import { ComSeriveProvider } from '../providers/com-serive/com-serive';
import { LinergradientServiceProvider } from '../providers/linergradient-service/linergradient-service';
import { CameraServiceProvider } from '../providers/camera-service/camera-service';
import { TeamSeriveProvider } from '../providers/team-serive/team-serive';  
import { PcSeriveProvider } from '../providers/pc-serive/pc-serive'; 
import { SlidePhotoPageModule } from '../components/camera/slide-photo/slide-photo.module';
import { UploadApi } from '../providers/api/upload';
import { MobileAccessibility } from '@ionic-native/mobile-accessibility';
import { FormsModule } from '@angular/forms';
// 多级联动
import { MultiPickerModule } from 'ion-multi-picker';

import {BrowserAnimationsModule} from '@angular/platform-browser/animations';


export function createTranslateLoader(http: HttpClient) {
  return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

export function provideSettings(storage: Storage) {
  /**
   * The Settings provider takes a set of default settings for your app.
   *
   * You can add new settings options at any time. Once the settings are saved,
   * these values will not overwrite the saved values (this can be done manually if desired).
   */
  return new Settings(storage, {
    option1: true,
    option2: 'Ionitron J. Framework',
    option3: '3',
    option4: 'Hello'
  });
}

@NgModule({ 
  declarations: [MyApp],
  imports: [  
    BrowserModule,
    BrowserAnimationsModule,
    HttpClientModule,
    MultiPickerModule, // 多级联动
    IndexListModule,
    
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: createTranslateLoader,
        deps: [HttpClient]
      }
    }),
    IonicStorageModule.forRoot(),
    IonicModule.forRoot(MyApp, {
      mode: 'ios', 
      tabsHideOnSubPages: true,
      backButtonText: '',
      backButtonIcon:'fanhui' 
    }),
    IonicStorageModule.forRoot(),
    SlidePhotoPageModule,
    FormsModule
  ],
  bootstrap: [IonicApp],
  entryComponents: [MyApp],
  providers: [
    Api,
    Items,
    User,
    Camera,
    File,
    FileTransfer,
    SplashScreen,
    StatusBar,
    { provide: Settings, useFactory: provideSettings, deps: [Storage] },
    // Keep this to enable Ionic's runtime error handling during development
    { provide: ErrorHandler, useClass: IonicErrorHandler },
    HttpSeriveProvider,
    MySeriveProvider,
    ComSeriveProvider,
    TeamSeriveProvider,
    LinergradientServiceProvider,
    CameraServiceProvider,
    TeamSeriveProvider,
    PcSeriveProvider,
    MobileAccessibility,
    UploadApi
  ]
})
export class AppModule {}
